#ifndef _NBIOT_H_
#define _NBIOT_H_

#include "message.h"

typedef enum{
	NB_OK = 0,
	NB_TIMEOUT = 1,
	NB_ERROR = 2,
	NB_DATA_IN = 3,
	NB_NET_CLOSED = 4,
	NB_REG_CHANGED = 5
}NB_STA;

void nbiot_send_at_cmd(char *pcCmd, int iDelay);
NB_STA nbiot_recv_at_resp(int iTry, char *pcResp, int *piSz);

NB_STA nbiot_module_init(void);
NB_STA nbiot_OceanConnect_init(void);

NB_STA nbiot_get_module_info(Message *pstMsg);

NB_STA nbiot_module_switch(char cSwitch);
void nbiot_module_restart(void);

NB_STA nbiot_check_reg(int iTimeout);
NB_STA nbiot_get_signl_val(char *pcSigVal);
NB_STA nbiot_get_reg_sta(char *pcRegSta, char *pcLBS);
NB_STA nbiot_get_nuestats(int *piRSRP, int *piSNR, int *piCellID, unsigned char *pucECL);

NB_STA nbiot_dns(const char *pcHost, char *pcIP, int iTimeout);

int nbiot_create_upd(int iPort);
NB_STA nbiot_udp_send(char *pcIP, int iPort, int socketId, unsigned char *pucData, int iLen, int iTimeout);

int nbiot_create_tcp(int iPort);
NB_STA nbiot_tcp_connect(int fd, char *pcIP, int iPort);
NB_STA nbiot_tcp_send(int socketId, unsigned char *pucData, int iLen, int iTimeout);

NB_STA nbiot_wait_data(Message *pstMsg, int iTimeout);
NB_STA nbiot_data_recv(int iFd, int *piRlen, unsigned char *pcOut, int iSz, int iTimeout);

NB_STA nbiot_close_socket(int iFd);

NB_STA nbiot_coap_send(char *pcMsg, int iLen, int iTimeout);
NB_STA nbiot_coap_wait(Message *pstMsg, int iTimeout);

#endif

